<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增评论详情')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content" th:fragment="commenter">
        <form class="form-horizontal m" id="form-blogcomment-add">
            <div class="form-group">
				<label for="name"><span>我有话说：</span></label>
				<!-- <textarea id="content" name="content" class="form-control" require="" rows="3" placeholder="请输入评论内容" onkeyup="if(event.keyCode==13) {document.getElementById('fs').click();}"></textarea> 按Enter键时调用click事件 onkeyup="if(event.keyCode==13) {document.getElementById('fs').click();}"-->
				<textarea id="content" name="content" class="form-control" rows="3" placeholder="温馨提示：本站已实现游客留言，点击右下角游客留言即可直接留言!" ></textarea>
			</div>
            <div class="form-group hidden">    
                <div class="col-sm-8">
	                <input name="pid" class="form-control" type="text">
	                <input name="contentId" th:value="${content.contentId}" class="form-control" type="text">
	                <input name="type" class="form-control" type="text">
                    <input name="plnrid" class="form-control" type="text">
                </div>
            </div>
            <div class="row" id="isverify" style="display:none">
                <div class="col-xs-3">
				    <input type="text" name="validateCode" class="form-control code" placeholder="验证码" width="30%" maxlength="5" />
				</div>
				<div class="col-xs-3">
					<a href="javascript:void(0);" title="点击更换验证码">
						<img th:src="@{/captcha/captchaImage(type=math)}" class="imgcode" height="33" width="66%"/>
					</a>
				</div>
            </div>
            <div style="text-align:right">
			    <a id="ykhh" onclick="ykhh()" style="text-decoration:none;display:block;font-size:10px;" title="无需登录直接留言"><span>游客留言</span></a>
			    <a id="zhhh" onclick="zhhh()" style="display:none;text-decoration:none;font-size:10px;"><span>账号留言</span></a><br/>
				<a id="fs" href="javascript:void(0)" style="display:block;text-decoration:none;" onclick="comment()"><span>发送 &rarr;</span></a>
				<a  id="ykfs" href="javascript:void(0)" style="display:none;text-decoration:none;" onclick="yksave()"><span>游客发送 &rarr;</span></a>
			</div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "blog/blogcomment";
        
        $("#form-blogcomment-add").validate({
            focusCleanup: true
        });
        
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-blogcomment-add').serialize());
            }
        }

        $("input[name='createDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            $('.summernote').summernote({
                lang: 'zh-CN',
                callbacks: {
                    onChange: function(contents, $edittable) {
                        $("input[name='" + this.id + "']").val(contents);
                    },
                    onImageUpload: function(files) {
                    	var obj = this;
                    	var data = new FormData();
                    	data.append("file", files[0]);
                    	$.ajax({
                    		type: "post",
                    		url: ctx + "common/upload",
                    		data: data,
                    		cache: false,
                    		contentType: false,
                    		processData: false,
                    		dataType: 'json',
                    		success: function(result) {
                    			if (result.code == web_status.SUCCESS) {
                    				$('#' + obj.id).summernote('insertImage', result.url);
                    			} else {
                    				$.modal.alertError(result.msg);
                    			}
                    		},
                    		error: function(error) {
                    			$.modal.alertWarning("图片上传失败。");
                    		}
                    	});
                    }
                }
            });
        });
    </script>
</body>
</html>